home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / C / StartDPK / AsmStartDPK.s < prev    next >
Encoding:
Text File  |  1998-05-08  |  2.3 KB  |  90 lines

  1. ;-------T-------T------------------------T------------------------------------------;
  2.  
  3.     xdef    _LaunchTask
  4.     xdef    _DPKBase
  5.  
  6.     INCDIR    "GMSDev:Includes/"
  7.     INCLUDE    "dpkernel/dpkernel.i"
  8.     INCLUDE    "files/segments.i"
  9.     INCLUDE    "system/tasks.i"
  10.  
  11. ;===================================================================================;
  12. ;                                    LAUNCH CODE
  13. ;===================================================================================;
  14. ;This part had to be written in assembler due to the InitDestruct() code, which
  15. ;requires a correct stack pointer.
  16.  
  17.     SECTION    "LaunchTask",CODE
  18.  
  19. _LaunchTask:
  20.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save registers.
  21.     move.l    a0,a5    ;a5 = Segment.
  22.     move.l    a1,a4    ;a4 = StartUp.
  23.  
  24.     ;Initialise self-destruct sequence.
  25.  
  26.     move.l    _DPKBase(pc),a6    ;a6 = DPKBase.
  27.     lea    .exit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  28.     move.l    a7,a1    ;a1 = Stack pointer.
  29.     CALL    InitDestruct    ;>> = Initialise the call.
  30.  
  31.     ;Setup parameters here.  Search for
  32.     ;"PRGM" header to launch program.
  33.  
  34.     move.l    SEG_Address(a5),a0    ;a0 = Segment start.
  35.     move.l    a0,a1
  36.     lea    64(a1),a1
  37. .loop    cmp.l    a1,a0
  38.     bgt.s    .exit
  39.     cmp.w    #"PR",(a0)+
  40.     bne.s    .loop
  41.     cmp.w    #"GM",(a0)+
  42.     bne.s    .loop
  43.     subq.w    #4,a0
  44.  
  45.     ;Table is now in a0.
  46.  
  47.     move.l    _DPKBase(pc),a6
  48.     CALL    FindDPKTask
  49.     tst.l    d0
  50.     beq.s    .exit
  51.     move.l    d0,a1    ;a1 = DPKTask
  52.  
  53.     move.l    _DPKBase(pc),GT_DPKBase(a1)
  54.     move.l    _DPKBase(pc),GT_GVBase(a1)
  55.     move.l    #$00,GT_Args(a1)    ;No arg support yet.
  56.  
  57.     move.w    DPK_DPKType(a0),GT_DPKTable(a1)
  58.     move.l    DPK_Start(a0),GT_Code(a1)
  59.     move.l    DPK_Name(a0),GT_Name(a1)
  60.     move.l    DPK_Author(a0),GT_Author(a1)
  61.     move.l    DPK_Date(a0),GT_Date(a1)
  62.     move.l    DPK_Copyright(a0),GT_Copyright(a1)
  63.     move.l    DPK_Short(a0),GT_Short(a1)
  64.     move.w    DPK_MinVersion(a0),GT_MinVersion(a1)
  65.     move.w    DPK_MinRevision(a0),GT_MinRevision(a1)
  66.  
  67.     move.l    a1,a0    ;a0 = DPKTask
  68.     sub.l    a1,a1    ;a1 = Null
  69.     sub.l    a2,a2    ;a2 = Null
  70.     sub.l    a3,a3    ;a3 = Null
  71.     sub.l    a4,a4    ;a4 = Null
  72.     move.l    GT_Code(a0),a5    ;a5 = Code
  73.     cmp.l    #$00,a5    ;a5 = Check for NULL.
  74.     beq.s    .exit    ;>> = Error in structure, exit.
  75.     move.l    _DPKBase(pc),a6    ;a6 = DPKBase
  76.     move.l    #$00,d0    ;d0 = ID
  77.     moveq    #$00,d1    ;d1 = Null
  78.     moveq    #$00,d2    ;d2 = Null
  79.     moveq    #$00,d3    ;d3 = Null
  80.     moveq    #$00,d4    ;d4 = Null
  81.     moveq    #$00,d5    ;d5 = Null
  82.     moveq    #$00,d6    ;d6 = Null
  83.     moveq    #$00,d7    ;d7 = Null
  84.     jsr    (a5)    ;>> = Start the DPK program.
  85. .exit    MOVEM.L    (SP)+,D0-D7/A0-A6
  86.     rts
  87.  
  88. _DPKBase:    dc.l  0
  89.  
  90.